home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / inpedit.com / INPEDIT2.BAS < prev    next >
Encoding:
BASIC Source File  |  1989-12-11  |  23.4 KB  |  739 lines

  1. DECLARE SUB EditField (HdrLine$, NumFields%, InfoRow%, HeaderRow%, ValidChar$, ValidMsgRow%)
  2. DECLARE SUB Pause ()
  3. DECLARE SUB ErrorSound ()
  4.  
  5. COMMON SHARED False, True
  6.  
  7. NumFields% = 9      'assign number of fields
  8. MaxFieldLen% = 60   'assign the size of largest input field
  9.  
  10.  
  11. DIM SHARED StringHolder$(NumFields%, MaxFieldLen% + 1)
  12.  
  13. DIM SHARED FieldName$(9)       'descriptor for field - Name:, Address:,etc
  14. DIM SHARED FieldNameRow%(9)   'starting row # for title field
  15. DIM SHARED FieldNameCol%(9)   'starting col # for title field
  16. DIM SHARED FieldLength%(9)    'max allowable num chars input
  17. DIM SHARED ValidMsg$(9)       'message to display for each field
  18. DIM SHARED InputRow%(9)       'starting row # for input field
  19. DIM SHARED InputCol%(9)       'starting col # for input field
  20. DIM SHARED InputString$(9)    'user input placed into this array
  21.  
  22. False = 0
  23. True = NOT False
  24.  
  25.  
  26.  
  27. HdrLine$ = "CUSTOMER DATA"
  28. NumFields% = 9
  29. MaxFieldLen% = 20  'size of the largest input field
  30. ValidMsgRow% = 20  'validation message row #
  31. InfoRow% = 22    'Info message display row
  32. HeaderRow% = 3     'row # for header...hdr col is calculated for auto-centering
  33.  
  34. ValidChar$ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789. -&"
  35.  
  36. '----------- Define the field layout data for editor screen ---------------
  37.  
  38. 'field # 1
  39. FieldName$(1) = "Name : "
  40. FieldLength%(1) = 20
  41. ValidMsg$(1) = " Please Enter Customer Name, 20 Characters Max, HARRY T. JONES"
  42. FieldNameRow%(1) = 5
  43. FieldNameCol%(1) = 3
  44. InputRow%(1) = 5
  45. InputCol%(1) = FieldNameCol%(1) + LEN(FieldName$(1))
  46. InputString$(1) = ""  'can assign a default val here - user may accept/change
  47.  
  48. 'field # 2
  49. FieldName$(2) = "Address : "
  50. FieldLength%(2) = 20
  51. ValidMsg$(2) = " Please Enter Address, 20 Characters Max, 1234 W. MAIN ST."
  52. FieldNameRow%(2) = 5
  53. FieldNameCol%(2) = 42
  54. InputRow%(2) = 5
  55. InputCol%(2) = FieldNameCol%(2) + LEN(FieldName$(2))
  56. InputString$(2) = ""   'can place a default value here
  57.  
  58. 'field # 3
  59. FieldName$(3) = "City : "
  60. FieldLength%(3) = 9
  61. ValidMsg$(3) = " Please Enter City Name, 12 Characters Max, 'PHOENIX'"
  62. FieldNameRow%(3) = 8
  63. FieldNameCol%(3) = 3
  64. InputRow%(3) = 8
  65. InputCol%(3) = FieldNameCol%(3) + LEN(FieldName$(3))
  66. InputString$(3) = ""   'can place a default value here
  67.  
  68. 'field # 4
  69. FieldName$(4) = "State : "
  70. FieldLength%(4) = 2
  71. ValidMsg$(4) = " Please Enter State Code, 2 Characters Max, 'AZ'"
  72. FieldNameRow%(4) = 8
  73. FieldNameCol%(4) = 42
  74. InputRow%(4) = 8
  75. InputCol%(4) = FieldNameCol%(4) + LEN(FieldName$(4))
  76. InputString$(4) = ""   'can place a default value here
  77.  
  78. 'field # 5
  79. FieldName$(5) = "Zip : "
  80. FieldLength%(5) = 5
  81. ValidMsg$(5) = " Please Enter ZIP Code, 5 Digits, '85345'"
  82. FieldNameRow%(5) = 8
  83. FieldNameCol%(5) = 65
  84. InputRow%(5) = 8
  85. InputCol%(5) = FieldNameCol%(5) + LEN(FieldName$(5))
  86. InputString$(5) = ""   'can place a default value here
  87.  
  88. 'field # 6
  89. FieldName$(6) = "Phone : "
  90. FieldLength%(6) = 12
  91. ValidMsg$(6) = " Please Enter Area Code and Phone Number, 12 Digits, '602 555-1212'"
  92. FieldNameRow%(6) = 11
  93. FieldNameCol%(6) = 3
  94. InputRow%(6) = 11
  95. InputCol%(6) = FieldNameCol%(6) + LEN(FieldName$(6))
  96. InputString$(6) = ""   'can place a default value here
  97.  
  98. 'field # 7
  99. FieldName$(7) = "Account Number : "
  100. FieldLength%(7) = 10
  101. ValidMsg$(7) = " Please Enter Account Number, 10 Digits, '25A1714TR3'"
  102. FieldNameRow%(7) = 14
  103. FieldNameCol%(7) = 3
  104. InputRow%(7) = 14
  105. InputCol%(7) = FieldNameCol%(7) + LEN(FieldName$(7))
  106. InputString$(7) = ""   'can place a default value here
  107.  
  108. 'field # 8
  109. FieldName$(8) = "Account Balance : "
  110. FieldLength%(8) = 8
  111. ValidMsg$(8) = " Please Enter Account Balance, 50000.00 Max, Do NOT Include '$' Sign"
  112. FieldNameRow%(8) = 14
  113. FieldNameCol%(8) = 42
  114. InputRow%(8) = 14
  115. InputCol%(8) = FieldNameCol%(8) + LEN(FieldName$(8))
  116. InputString$(8) = ""   'can place a default value here
  117.  
  118. 'field # 9
  119. FieldName$(9) = "Comments : "
  120. FieldLength%(9) = 60
  121. ValidMsg$(9) = " Please Enter Comments 60 Characters Max"
  122. FieldNameRow%(9) = 17
  123. FieldNameCol%(9) = 3
  124. InputRow%(9) = 17
  125. InputCol%(9) = FieldNameCol%(9) + LEN(FieldName$(9))
  126. InputString$(9) = ""   'can place a default value here
  127.  
  128. '----------------define editor control data-------------------------
  129.  
  130. DO
  131.  
  132.    CALL EditField(HdrLine$, NumFields%, InfoRow%, HeaderRow%, ValidChar$, ValidMsgRow%)
  133.  
  134.    'reassign for convenience-if there are many numeric fields to test, a
  135.    'line longer than 255 characters may result if we don't use short scalars
  136.    a$ = InputString$(1)   'name
  137.    B$ = InputString$(2)   'address
  138.    C$ = InputString$(3)   'city
  139.    D$ = InputString$(4)   'state
  140.    E$ = InputString$(5)   'zip
  141.    F$ = InputString$(6)   'phone
  142.    G$ = InputString$(7)   'acct #
  143.    H$ = InputString$(8)   'acct bal
  144.    I$ = InputString$(9)   'comments
  145.  
  146.    'if you are calling the editor multiple times from within a loop, you
  147.    'may wish to null-out InputString$ (unless you wish the values from
  148.    'the previous screen to be defaults for the next screen)
  149.  
  150.    InputString$(1) = ""
  151.    InputString$(2) = ""
  152.    InputString$(3) = ""
  153.    InputString$(4) = ""
  154.    InputString$(5) = ""
  155.    InputString$(6) = ""
  156.    InputString$(7) = ""
  157.    InputString$(8) = ""
  158.    InputString$(9) = ""
  159.  
  160.    '        -- All character fields are validated within EditField --
  161.    '                   Validate numeric values here
  162.  
  163.    'did any numeric field exceed limits ? (this example screen has only 1)
  164.    IF VAL(H$) > 50000! THEN
  165.       ValsInLimit = False
  166.       CALL ErrorSound
  167.       CLS
  168.       LOCATE 12, 15
  169.       PRINT "All Fields Are Not Within Max Limits - Please Check"
  170.       CALL Pause
  171.    ELSE
  172.       ValsInLimit = True
  173.    END IF
  174.  
  175. LOOP UNTIL ValsInLimit
  176.  
  177. 'convert any fields which contain values rather than strings here
  178.  H1 = VAL(H$)
  179.  
  180. 'this section will print the results to screen-this is where you would
  181. 'normally assign the user-input values to your own pgm variables
  182.  
  183. CLS
  184. PRINT a$
  185. PRINT B$
  186. PRINT C$
  187. PRINT D$
  188. PRINT E$
  189. PRINT F$
  190. PRINT G$
  191. PRINT H1
  192. PRINT I$
  193.  
  194.  
  195. END
  196.  
  197. SUB EditField (HdrLine$, NumFields%, InfoRow%, HeaderRow%, ValidChar$, ValidMsgRow%)
  198. '
  199. '----------------------------------------------------------------------------
  200. '  Input    : Number of fields to be displayed in NumFields%, starting row
  201. '             numbers in InputRow%(), starting col #'s in InputCol%(), field
  202. '             names to display in FieldName$(), field lengths (for
  203. '             highlighting) in FieldLength%(), row & col on which to display
  204. '             field name in FieldNameRow%() & FieldNameCol%(), header title
  205. '             string to display in HdrLine$, row on which to display the
  206. '             header line (if any) HeaderRow%, list of valid characters which
  207. '             may be entered in ValidCar$, description displayed at bottom of
  208. '             display telling user what type of input is expected in
  209. '             ValidMsg$(), row on which to display ValidMsg$ in ValidMsgRow%,
  210. '             row # on which to display info on InfoRow%, valid characters to
  211. '             accept in ValidChar$.
  212. '  Process  : Sets up a screen editor which allows user to enter all
  213. '             pertinent data one field at a time. When user is satisfied,
  214. '             F1 is typed.
  215. '  Output   : Data entered into fields by user in 1-d array InputString$()
  216. '  Coupling : Called by Main
  217. '             Calls ErrorSound
  218. '
  219. '----------------------------------------------------------------------------
  220.  
  221. 'this array sets up a matrix of individual rows and column cells
  222. 'the editor loads one column location at a time-the array contents
  223. 'are re-assigned to a scalar, variable-length string array after user
  224. 'accepts the screen data-must have one extra col for insert mode
  225. '
  226. 'assign the key values to appropriate descriptors
  227. DNARROW$ = CHR$(0) + CHR$(80)
  228. UPARROW$ = CHR$(0) + CHR$(72)
  229. LFARROW$ = CHR$(0) + CHR$(75)
  230. RTARROW$ = CHR$(0) + CHR$(77)
  231. F1$ = CHR$(0) + CHR$(59)
  232. ENTER$ = CHR$(13)
  233. FWDTAB$ = CHR$(9)
  234. BKWDTAB$ = CHR$(0) + CHR$(15)
  235. DEL$ = CHR$(0) + CHR$(83)
  236. INS$ = CHR$(0) + CHR$(82)
  237. DELARROW$ = CHR$(8)
  238.  
  239. 'title line normal colors
  240. FrgdNorm% = 3
  241. BkgdNorm% = 0
  242. 'header line colors
  243. HdrFrgdNorm% = 14
  244. HdrBkgdNorm% = 0
  245. 'title highlight colors
  246. FrgdHi% = 4
  247. BkgdHi% = 7
  248. 'Info line color
  249. InfoFrgd% = 3
  250. InfoBkgd% = 0
  251. 'field data norm color
  252. FieldFrgdNorm% = 2
  253. FieldBkgdNorm% = 0
  254. 'field data highlite color
  255. FieldFrgdHi% = 4
  256. FieldBkgdHi% = 7
  257. 'insert off indicator colors
  258. InsOffFrgd% = 3
  259. InsOffBkgd% = 0
  260. 'insert on indicator colors
  261. InsOnFrgd% = 4
  262. InsOnBkgd% = 7
  263.  
  264. 'assign any default values passed in to the string matrix
  265. FOR FieldIndex% = 1 TO NumFields%
  266.  
  267.    FOR ColIndex% = 1 TO MaxFieldLen%
  268.       StringHolder$(FieldIndex%, ColIndex%) = MID$(InputString$(FieldIndex%), ColIndex%, 1)
  269.    NEXT ColIndex%
  270.  
  271.    'null out each row, we will re-assign before leaving routine
  272.    InputString$(FieldIndex%) = ""
  273.  
  274. NEXT FieldIndex%
  275.  
  276. 'Top of "Do Edit Routine Until User Is Sure He/She Wishes To Quit" Loop
  277. DO
  278.  
  279.    CLS
  280.  
  281.    'set default selection # to 1
  282.    FieldCtr% = 1
  283.    'display whole screen in normal colors
  284.    COLOR FrgdNorm%, BkgdNorm%, 0
  285.    'center the header line
  286.    HdrLineCol% = (80 - LEN(HdrLine$)) \ 2
  287.    COLOR HdrFrgdNorm%, HdrBkgdNorm%
  288.    LOCATE HeaderRow%, HdrLineCol%
  289.    PRINT HdrLine$
  290.  
  291.    COLOR FieldFrgdHi%, FieldBkgdHi%, 0
  292.    LOCATE ValidMsgRow%, 2
  293.    PRINT STRING$(77, " ")
  294.    LOCATE ValidMsgRow%, 2
  295.    PRINT ValidMsg$(FieldCtr%)
  296.  
  297.    LOCATE InfoRow%, 2
  298.    COLOR InfoFrgd%, InfoBkgd%, 0
  299.    PRINT "Use Arrows,TAB Or ENTER To Move Highlight Bar, ";
  300.    COLOR HdrFrgdNorm%, HdrBkgdNorm%
  301.    PRINT "<F1>";
  302.    COLOR InfoFrgd%, InfoBkgd%, 0
  303.    PRINT " When Done Editing Screen"
  304.  
  305.    InsertOn = False
  306.    'set cursor to small line-indicates insert off
  307.    CursorStart = 6
  308.    CursorStop = 7
  309.    InsStatus$ = " INSERT OFF "
  310.    LOCATE 2, 65
  311.    COLOR InsOffFrgd%, InsOffBkgd%, 0
  312.    PRINT InsStatus$
  313.  
  314.    COLOR FrgdNorm%, BkgdNorm%, 0
  315.  
  316.    'display the choices
  317.    FOR Ctr% = 1 TO NumFields%
  318.       'display all the field names and defaults (if any)
  319.       COLOR FrgdNorm%, BkgdNorm%, 0
  320.       LOCATE FieldNameRow%(Ctr%), FieldNameCol%(Ctr%)
  321.       PRINT FieldName$(Ctr%);
  322.       COLOR FieldFrgdNorm%, FieldBkgdNorm%, 0
  323.       'input string may either be empty or contain defaults
  324.       LOCATE InputRow%(Ctr%), InputCol%(Ctr%)
  325.  
  326.       FOR I% = 1 TO FieldLength%(Ctr%)
  327.          PRINT StringHolder$(Ctr%, I%);
  328.          LOCATE InputRow%(Ctr%), InputCol%(Ctr%) + I%
  329.       NEXT I%
  330.  
  331.       LOCATE InputRow%(Ctr%), InputCol%(Ctr%)
  332.  
  333.    NEXT Ctr%
  334.  
  335.    Index% = 1
  336.    CharCtr% = 1
  337.    FieldCtr% = 1
  338.    Row% = InputRow%(FieldCtr%)
  339.    Col% = InputCol%(FieldCtr%)
  340.  
  341.    'we will highlight 1st selection when menu comes up, row 1 col 1
  342.    HiLiteRow% = InputRow%(FieldCtr%)
  343.    HiLiteCol% = InputCol%(FieldCtr%)
  344.  
  345.    GOSUB HIGHLIGHT
  346.  
  347.    LOCATE InputRow%(FieldCtr%), InputCol%(FieldCtr%), 0
  348.  
  349.    'Top of "Do <Edit Any Field> Until User Hits Enter Key" loop
  350.    DO
  351.       'Top of "Do <Get Key> Until User Hits a Key" loop
  352.       DO
  353.          'may be 1 or 2 bytes long
  354.          Ky$ = INKEY$
  355.          'put cursor where it belongs while waiting for input
  356.          LOCATE Row%, Col%, 1, CursorStart, CursorStop
  357.  
  358.       LOOP UNTIL LEN(Ky$) > 0
  359.  
  360.       LOCATE , , 1, CursorStart, CursorStop
  361.       'include this statement to change all to uppercase
  362.       'Ky$ = UCASE$(Ky$)
  363.  
  364.       SELECT CASE Ky$
  365.  
  366.          '***************        INSERT KEY TOGGLED           ****************
  367.  
  368.          CASE IS = INS$
  369.  
  370.          'toggle the insert status var
  371.          IF InsertOn THEN
  372.             InsertOn = False
  373.             CursorStart = 7
  374.             CursorStop = 7
  375.             InsStatus$ = " INSERT OFF "
  376.             LOCATE 2, 65
  377.             COLOR InsOffFrgd%, InsOffBkgd%, 0
  378.             PRINT InsStatus$
  379.             COLOR 4, 7, 0
  380.             LOCATE InputRow%(FieldCtr%), InputCol%(FieldCtr%), 1, CursorStart, CursorStop
  381.  
  382.          'toggle the insert status var to on
  383.          ELSEIF NOT InsertOn THEN
  384.             InsertOn = True
  385.             'change to block cursor
  386.             CursorStart = 0
  387.             CursorStop = 7
  388.             InsStatus$ = " INSERT ON  "
  389.             LOCATE 2, 65
  390.             COLOR InsOnFrgd%, InsOnBkgd%, 0
  391.             PRINT InsStatus$
  392.             LOCATE InputRow%(FieldCtr%), InputCol%(FieldCtr%), 1, CursorStart, CursorStop
  393.          END IF
  394.  
  395.          '****************** FORWARD TAB OR <CR> PRESSED *********************
  396.  
  397.          CASE IS = FWDTAB$, ENTER$, DNARROW$
  398.             'un-highlight the old field
  399.             NormRow% = InputRow%(FieldCtr%)
  400.             NormCol% = InputCol%(FieldCtr%)
  401.  
  402.             GOSUB NORMAL
  403.  
  404.             'did we advance or rollback to top ?
  405.             IF FieldCtr% = NumFields% THEN
  406.                'when a col rollup occurs, the value of FieldCtr% goes back to 1
  407.                FieldCtr% = 1
  408.             ELSE
  409.                FieldCtr% = FieldCtr% + 1
  410.             END IF
  411.  
  412.             Row% = InputRow%(FieldCtr%)
  413.  
  414.             'highlight the next field
  415.             HiLiteRow% = InputRow%(FieldCtr%)
  416.             HiLiteCol% = InputCol%(FieldCtr%)
  417.             Col% = InputCol%(FieldCtr%)
  418.             Index% = 1
  419.             CharCtr% = 1
  420.  
  421.             GOSUB HIGHLIGHT
  422.  
  423.             LOCATE InputRow%(FieldCtr%), InputCol%(FieldCtr%), 1, CursorStart, CursorStop
  424.             'user is changing fields so init vars
  425.             COLOR FieldFrgdHi%, FieldBkgdHi%, 0
  426.             LOCATE ValidMsgRow%, 2
  427.             PRINT STRING$(77, " ")
  428.             LOCATE ValidMsgRow%, 2
  429.             PRINT ValidMsg$(FieldCtr%)
  430.  
  431.          '***************   UP ARROW OR SHIFT-TAB PRESSED ********************
  432.  
  433.          CASE IS = BKWDTAB$, UPARROW$
  434.  
  435.             'un-highlight the old field
  436.             NormRow% = InputRow%(FieldCtr%)
  437.             NormCol% = InputCol%(FieldCtr%)
  438.             GOSUB NORMAL
  439.  
  440.             'are we about to wrapdown to bot of list ?
  441.             IF FieldCtr% = 1 THEN
  442.                'when wrapping to last field occurs, the value of FieldCtr%
  443.                'becomes the largest field number
  444.                FieldCtr% = NumFields%
  445.             ELSE
  446.                FieldCtr% = FieldCtr% - 1
  447.             END IF
  448.  
  449.             'we were at first field, so we are now going to wrap to last field
  450.             Row% = InputRow%(FieldCtr%)
  451.  
  452.             HiLiteRow% = Row%
  453.             HiLiteCol% = InputCol%(FieldCtr%)
  454.             Col% = InputCol%(FieldCtr%)
  455.             Index% = 1
  456.             CharCtr% = 1
  457.  
  458.             GOSUB HIGHLIGHT
  459.  
  460.             COLOR FieldFrgdHi%, FieldBkgdHi%, 0
  461.             LOCATE ValidMsgRow%, 2
  462.             PRINT STRING$(77, " ")
  463.             LOCATE ValidMsgRow%, 2
  464.             PRINT ValidMsg$(FieldCtr%)
  465.  
  466.          '****************      LEFT  ARROW  PRESSED        ******************
  467.  
  468.          CASE IS = LFARROW$
  469.  
  470.          'can we move to the left in this field?
  471.          IF Index% > 1 THEN
  472.             'dec col ctr
  473.             Col% = Col% - 1
  474.             'dec array ptr
  475.             Index% = Index% - 1
  476.             'dec char counter
  477.             CharCtr% = CharCtr% - 1
  478.             'reposition cursor
  479.             LOCATE Row%, Col%
  480.          ELSE
  481.             SOUND 4200, 1
  482.          END IF
  483.  
  484.          '****************     RIGHT  ARROW  PRESSED        ******************
  485.  
  486.          CASE IS = RTARROW$
  487.  
  488.             'can we still move to the right in this field?
  489.             IF Index% < (FieldLength%(FieldCtr%)) THEN
  490.                'inc col ctr
  491.                Col% = Col% + 1
  492.                'inc array ptr
  493.                Index% = Index% + 1
  494.                CharCtr% = CharCtr% + 1
  495.                'reposition cursor
  496.                LOCATE Row%, Col%
  497.             ELSE
  498.                SOUND 4200, 1
  499.             END IF
  500.  
  501.          '****************      DELETE KEY PRESSED        ******************
  502.  
  503.          CASE IS = DEL$
  504.  
  505.             IF Index% > 0 THEN
  506.  
  507.                'we deleted char in position 'Index%, so pull all char's
  508.                'which are to the right of that char one to the left
  509.                FOR ColIndx% = Index% TO (FieldLength%(FieldCtr%) - 1)
  510.                   StringHolder$(FieldCtr%, ColIndx%) = StringHolder$(FieldCtr%, (ColIndx% + 1))
  511.                NEXT ColIndx%
  512.                StringHolder$(FieldCtr%, FieldLength%(FieldCtr%)) = " "
  513.                'blank out the whole field, then re-print new value
  514.                LOCATE Row%, InputCol%(FieldCtr%), 0
  515.                'print out the whole reconstructed array for this field
  516.                FOR I% = 1 TO (FieldLength%(FieldCtr%))
  517.                   PRINT StringHolder$(FieldCtr%, I%);
  518.                NEXT I%
  519.             END IF
  520.  
  521.          '****************    DELETE ARROW PRESSED        ******************
  522.  
  523.          CASE IS = DELARROW$
  524.  
  525.             IF Index% > 1 THEN
  526.                'we deleted char in position 'Index%, so pull all char's
  527.                'which are to the right of that char one to the left
  528.                FOR ColIndx% = Index% TO (FieldLength%(FieldCtr%) + 1)
  529.                   StringHolder$(FieldCtr%, ColIndx% - 1) = StringHolder$(FieldCtr%, (ColIndx%))
  530.                NEXT ColIndx%
  531.                StringHolder$(FieldCtr%, FieldLength%(FieldCtr%)) = " "
  532.                'back-up the cursor position
  533.                Col% = Col% - 1
  534.                'back-up the array ptr
  535.                Index% = Index% - 1
  536.                'subtract one character
  537.                CharCtr% = CharCtr% - 1
  538.                LOCATE Row%, InputCol%(FieldCtr%), 0
  539.                FOR I% = 1 TO (FieldLength%(FieldCtr%))
  540.                   PRINT StringHolder$(FieldCtr%, I%);
  541.                NEXT I%
  542.             ELSE
  543.                SOUND 4200, 1
  544.             END IF
  545.  
  546.             LOCATE Row%, Col%
  547.  
  548.          '******* SOMETHING ELSE BESIDES A DIRECTION KEY PRESSED ************
  549.  
  550.          CASE ELSE
  551.  
  552.             'if user didn't hit enter key, see if it is a valid char
  553.             IF Ky$ <> F1$ THEN
  554.                'is this a valid character ?
  555.                IF INSTR(ValidChar$, Ky$) THEN
  556.                   'do we still have room in this field ?
  557.                   IF Index% <= (FieldLength%(FieldCtr%)) THEN
  558.                      'is insert on or off ?
  559.                      IF NOT InsertOn THEN
  560.                         'insert is off, type over what is currently there
  561.                         StringHolder$(FieldCtr%, Index%) = Ky$
  562.                         LOCATE InputRow%(FieldCtr%), InputCol%(FieldCtr%) + (Index% - 1), 0
  563.                         Row% = InputRow%(FieldCtr%)
  564.                         Col% = InputCol%(FieldCtr%) + (Index% - 1)
  565.                         PRINT StringHolder$(FieldCtr%, Index%)
  566.  
  567.                      'insert is on, we must shove everything to the right
  568.                      ELSE
  569.                         'we inserted a char in position Index%, so push all char's
  570.                         'which are to the right of that char one more to the right
  571.                         '(must work backwards thru the string array to avoid overwriting)
  572.                         FOR ColIndx% = (FieldLength%(FieldCtr%) - 1) TO Index% STEP -1
  573.                            StringHolder$(FieldCtr%, ColIndx% + 1) = StringHolder$(FieldCtr%, (ColIndx%))
  574.                         NEXT ColIndx%
  575.  
  576.                         StringHolder$(FieldCtr%, Index%) = Ky$
  577.  
  578.                         'blank out the whole field, then re-print new value
  579.                         LOCATE Row%, InputCol%(FieldCtr%), 0
  580.  
  581.                         FOR I% = 1 TO (FieldLength%(FieldCtr%))
  582.                            PRINT StringHolder$(FieldCtr%, I%);
  583.                         NEXT I%
  584.  
  585.                      END IF
  586.  
  587.                      'if not at tail of list, advance ctrs
  588.                      IF Index% < FieldLength%(FieldCtr%) THEN
  589.                         Col% = Col% + 1
  590.                         Index% = Index% + 1
  591.                         'user typed a valid character
  592.                         CharCtr% = CharCtr% + 1
  593.                      ELSE
  594.                         'just typed the last allowable char for this field,
  595.                         'give a mild peep sound
  596.                         SOUND 4200, 1
  597.                      END IF
  598.  
  599.                   ELSE
  600.                      'max num chars this field, give mild peep sound
  601.                      SOUND 4200, 1
  602.                   END IF
  603.  
  604.                ELSE
  605.                   'not a valid character-give error beep
  606.                   CALL ErrorSound
  607.                END IF
  608.  
  609.             ELSE
  610.                'user hit F1 key, assign the values in string array
  611.                'to the  input-string fields, one field at a time
  612.                FOR I% = 1 TO NumFields%
  613.                   'null-out each row before assigning
  614.                   InputString$(I%) = ""
  615.                   'unload each row of the matrix into it's corresponding
  616.                   'array location in InputString()
  617.                   FOR J% = 1 TO FieldLength%(I%)
  618.                      InputString$(I%) = InputString$(I%) + StringHolder$(I%, J%)
  619.                   NEXT J%
  620.                      InputString$(I%) = RTRIM$(LTRIM$(InputString$(I%)))
  621.                NEXT I%
  622.  
  623.             END IF
  624.  
  625.       END SELECT
  626.  
  627.    LOOP UNTIL Ky$ = F1$
  628.  
  629.    COLOR FrgdNorm%, BkgdNorm%, 0
  630.    'clear the msg line area
  631.    FOR I% = 1 TO 3
  632.       LOCATE 19 + I%, 2
  633.       PRINT STRING$(77, " ")
  634.    NEXT I%
  635.  
  636.    LOCATE InfoRow%, 3
  637.    COLOR FrgdHi%, BkgdHi%, 0
  638.    PRINT " Exit Editor And Save Current Values...Are You Sure? (Y/N):  "
  639.    LOCATE InfoRow%, 62
  640.    INPUT "", Ans$
  641.    Ans$ = UCASE$(Ans$)
  642.  
  643.    COLOR FrgdNorm%, BkgdNorm%, 0
  644.    LOCATE InfoRow%, 2
  645.    PRINT STRING$(77, " ")
  646.  
  647. LOOP UNTIL Ans$ = "Y"
  648.  
  649. 'jump around the highlite routines
  650. GOTO Bottom
  651.  
  652. ' these routines are written as internal subs instead of external for
  653. ' convenience only-change to ext subs and pass the parameters if you wish
  654.  
  655. '----------------Normal & Highlight Routines-----------------
  656. NORMAL:
  657.  
  658.    'return highlighted field to normal
  659.    COLOR FieldFrgdNorm%, FieldBkgdNorm%, 0
  660.  
  661.    LOCATE NormRow%, NormCol%, 0
  662.    PRINT STRING$(FieldLength%(FieldCtr%), " ")
  663.    LOCATE NormRow%, NormCol%, 0
  664.  
  665.    FOR I% = 1 TO FieldLength%(FieldCtr%)
  666.       PRINT StringHolder$(FieldCtr%, I%);
  667.       LOCATE NormRow%, NormCol% + I%, 0
  668.    NEXT I%
  669.  
  670. RETURN
  671.  
  672. HIGHLIGHT:
  673.  
  674.    'highlight the new field
  675.    COLOR FieldFrgdHi%, FieldBkgdHi%, 0
  676.  
  677.    LOCATE HiLiteRow%, HiLiteCol%, 0
  678.    PRINT STRING$(FieldLength%(FieldCtr%), " ")
  679.    LOCATE HiLiteRow%, HiLiteCol%, 0
  680.  
  681.    FOR I% = 1 TO FieldLength%(FieldCtr%)
  682.       PRINT StringHolder$(FieldCtr%, I%);
  683.       LOCATE HiLiteRow%, HiLiteCol% + I%, 0
  684.    NEXT I%
  685.  
  686. RETURN
  687.  
  688. Bottom:
  689.  
  690. COLOR FrgdNorm%, BkgdNorm%, 0
  691.  
  692. END SUB
  693.  
  694. SUB ErrorSound STATIC
  695. '
  696. '-----------------------------------------------------------------------------
  697. '
  698. '  Input    : No values passed into routine
  699. '  Process  : Sends an error sound to the speaker
  700. '  Output   : No values passed out of routine
  701. '  Coupling : Called by EditField
  702. '             Calls no routines
  703. '
  704. '-----------------------------------------------------------------------------
  705.  
  706.    FOR Frequency% = 900 TO 900 STEP 900
  707.  
  708.       SOUND Frequency%, 1
  709.       SOUND Frequency% * (.785), 1
  710.  
  711.    NEXT Frequency%
  712.  
  713. END SUB
  714.  
  715. SUB Pause
  716. '
  717. '-----------------------------------------------------------------------------
  718. '
  719. '  Input    : No values passed into routine
  720. '  Process  : Displays a continue message and pauses program execution until
  721. '             user hits a key
  722. '  Output   : No values passed out of routine
  723. '  Coupling : Called by EditField
  724. '             Calls no routines
  725. '
  726. '-----------------------------------------------------------------------------
  727.  
  728.  
  729.   LOCATE 21, 3, 0
  730.   PRINT "Type Any Key To Continue..."
  731.  
  732.   DO
  733.      t$ = INKEY$
  734.   LOOP UNTIL t$ <> ""
  735.  
  736.  
  737. END SUB
  738.  
  739.